package com.common.work.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.common.account.service.IAuUserService;
import com.common.basis.entity.User;
import com.common.basis.oauth.AuUser;
import com.common.basis.result.Result;
import com.common.basis.result.ResultSet;
import com.common.basis.util.AuthUtils;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@AllArgsConstructor
@RequestMapping("/test")
public class TestController {
    private final IAuUserService iAuUserService;


    /**
     * 用户
     *
     * @return {@link Result}<{@link List}<{@link AuUser}>>
     */
    @GetMapping("user")
    public Result<List<AuUser>> user() {
        User user = AuthUtils.getUser();
        String username = user.getUsername();
        LambdaQueryWrapper<AuUser> query = Wrappers.lambdaQuery();
        List<AuUser> list = iAuUserService.list(query);
        return ResultSet.go(list);
    }

    /**
     * 管理
     *
     * @return {@link String}
     */
    @GetMapping("admin")
    public String admin() {
        return "admin";
    }
}
